<template>
  <div class="goods-management-view">
    <!-- 筛选区和设置图标同一行 -->
    <div class="filter-bar">
      <div class="filter-area">
        <el-select
          v-model="selectedCategory"
          placeholder="选择类别"
          clearable
          size="small"
          style="width: 150px; margin-left: 10px;"
          @change="handleSearch"
        >
          <el-option
            v-for="item in categoryList"
            :key="item.id"
            :label="item.category_name"
            :value="item.id">
          </el-option>
        </el-select>
        <el-input
          v-model="searchQuery"
          placeholder="商品名称"
          prefix-icon="el-icon-search"
          size="small"
          style="width: 200px; margin-left: 10px; --el-input-bg-color: #f5f7fa;"
        ></el-input>
        <el-button type="primary" size="small" style="margin-left: 10px;" @click="handleSearch">搜索</el-button>
        <el-button size="small" @click="resetSearch">重置</el-button>
        <el-button type="primary" size="small" style="margin-left: 10px;" @click="handleAdd">新增商品</el-button>
      </div>
      <div class="filter-setting-icon">
        <el-popover
          placement="bottom-end"
          width="200"
          trigger="click"
          v-model="showColumnSetting"
        >
          <div v-for="col in columns" :key="col.key" v-if="col.key !== 'selection' ">
            <el-checkbox v-model="col.visible">{{ col.label }}</el-checkbox>
          </div>
          <div style="text-align: right;">
            <el-button type="text" size="mini" @click="resetColumns">重置</el-button>
          </div>
          <i
            class="el-icon-setting"
            slot="reference"
            style="cursor: pointer; font-size: 20px; margin-left: 10px;"
          ></i>
        </el-popover>
      </div>
    </div>

    <!-- 数据表格 - 移动端滚动容器 -->
    <div class="table-wrapper">
      <el-table ref="goodsTable" :data="goodsData" style="width: 100%;" border @selection-change="handleSelectionChange">
      <el-table-column v-if="getColumnVisible('selection')" type="selection" width="40"></el-table-column>
      <el-table-column v-if="getColumnVisible('index')" label="序号" width="60">
        <template slot-scope="scope">
          {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
     
      <el-table-column v-if="getColumnVisible('goods_name')" prop="goods_name" label="商品名称" min-width="200"></el-table-column>
      <el-table-column v-if="getColumnVisible('category_name')" label="商品类别" min-width="120">
        <template slot-scope="scope">
          {{ scope.row.category ? scope.row.category.category_name : '-' }}
        </template>
      </el-table-column>
      <el-table-column v-if="getColumnVisible('goods_img')" prop="goods_img" label="商品图片" width="120" align="center">
        <template slot-scope="scope">
          <el-image
            v-if="getFirstImage(scope.row.goods_img)"
            :src="getFirstImage(scope.row.goods_img)"
            :preview-src-list="getImageList(scope.row.goods_img)"
            style="width: 60px; height: 60px;"
            fit="cover"
          ></el-image>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column v-if="getColumnVisible('amount')" prop="amount" label="原价" width="100" align="center">
        <template slot-scope="scope">
          {{ scope.row.amount ? '¥' + scope.row.amount : '-' }}
        </template>
      </el-table-column>
      <el-table-column v-if="getColumnVisible('discount')" prop="discount" label="折扣价" width="100" align="center">
        <template slot-scope="scope">
          {{ scope.row.discount ? '¥' + scope.row.discount : '-' }}
        </template>
      </el-table-column>
      <el-table-column v-if="getColumnVisible('status')" prop="status" label="状态" width="100" align="center">
        <template slot-scope="scope">
          <el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">
            {{ scope.row.status === 1 ? '正常' : '禁用' }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column v-if="getColumnVisible('create_time')" prop="create_time" label="创建时间" min-width="180">
        <template slot-scope="scope">
          {{ formatDate(scope.row.create_time) }}
        </template>
      </el-table-column>
      <el-table-column v-if="getColumnVisible('operate')" label="操作" width="280" align="center" fixed="right">
        <template slot-scope="scope">
          <div style="display: flex; align-items: center; justify-content: center;">
            <el-switch
              v-model="scope.row.status"
              active-color="#13ce66"
              inactive-color="#ff4949"
              active-text="启用"
              inactive-text="禁用"
              :active-value="1"
              :inactive-value="0"
              size="small"
              @change="handleStatusChange(scope.row)"
            >
            </el-switch>
            <el-button type="text" size="small" style="margin-left: 10px;" @click="handleEdit(scope.row)">编辑</el-button>
            <el-button type="text" size="small" style="margin-left: 10px;" @click="handleView(scope.row)">查看</el-button>
            <el-button type="text" size="small" style="margin-left: 10px; color: #F56C6C;" @click="handleDelete(scope.row)">删除</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
      </div>

    <!-- 分页组件 -->
    <div class="pagination-container" style="text-align: right; margin-top: 10px;">
      <PageCom :total="total" :pageSize="pageSize" @handleSizeChange="handleSizeChange" @handleCurrentChange="handleCurrentChange"></PageCom>
    </div>

    <!-- 添加/编辑商品弹窗 -->
    <el-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      width="800px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      @close="resetForm"
    >
      <el-form :model="form" :rules="rules" ref="form" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="商品名称" prop="goods_name">
              <el-input v-model="form.goods_name" placeholder="请输入商品名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商品类别" prop="category_id">
              <el-select v-model="form.category_id" placeholder="请选择商品类别" style="width: 100%">
                <el-option
                  v-for="item in categoryList"
                  :key="item.id"
                  :label="item.category_name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="原价" prop="amount">
              <el-input-number v-model="form.amount" :min="0" :precision="2" placeholder="请输入原价" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="折扣价" prop="discount">
              <el-input-number v-model="form.discount" :min="0" :precision="2" placeholder="请输入折扣价" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" v-if="isEdit">
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <el-select v-model="form.status" placeholder="请选择状态" style="width: 100%">
                <el-option label="正常" :value="1"></el-option>
                <el-option label="禁用" :value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
         <el-form-item label="商品图片" prop="goods_img">
           <el-upload
             ref="upload"
             :file-list="fileList"
             :http-request="customUpload"
             :on-remove="handleRemove"
             :before-upload="beforeUpload"
             list-type="picture-card"
             :limit="5"
             :on-exceed="handleExceed"
             :auto-upload="true"
             :show-file-list="true"
             :on-preview="handlePreview"
             :on-change="handleFileChange"
           >
             <i class="el-icon-plus"></i>
           </el-upload>
           <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过2MB，最多5张。选择图片后立即上传</div>
         </el-form-item>
        <el-form-item label="商品描述" prop="description">
          <el-input
            v-model="form.description"
            type="textarea"
            :rows="4"
            placeholder="请输入商品描述"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCancel">取 消</el-button>
        <el-button type="primary" @click="submitForm" :loading="submitLoading">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 查看商品详情弹窗 -->
    <el-dialog
      title="商品详情"
      :visible.sync="viewDialogVisible"
      width="600px"
    >
      <el-descriptions :column="1" border>
        <el-descriptions-item label="商品名称">{{ viewData.goods_name }}</el-descriptions-item>
        <el-descriptions-item label="商品类别">
          {{ viewData.category ? viewData.category.category_name : '-' }}
        </el-descriptions-item>
        <el-descriptions-item label="原价">{{ viewData.amount ? '¥' + viewData.amount : '-' }}</el-descriptions-item>
        <el-descriptions-item label="折扣价">{{ viewData.discount ? '¥' + viewData.discount : '-' }}</el-descriptions-item>
        <el-descriptions-item label="状态">
          <el-tag :type="viewData.status === 1 ? 'success' : 'danger'">
            {{ viewData.status === 1 ? '正常' : '禁用' }}
          </el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="商品图片" v-if="getImageList(viewData.goods_img).length > 0">
          <el-image
            v-for="(img, index) in getImageList(viewData.goods_img)"
            :key="index"
            :src="img"
            style="width: 80px; height: 80px; margin-right: 10px; margin-bottom: 10px;"
            fit="cover"
            :preview-src-list="getImageList(viewData.goods_img)"
          ></el-image>
        </el-descriptions-item>
        <el-descriptions-item label="商品描述">{{ viewData.description || '-' }}</el-descriptions-item>
        <el-descriptions-item label="创建时间">{{ formatDate(viewData.create_time) }}</el-descriptions-item>
      </el-descriptions>
    </el-dialog>
  </div>
</template>

<script>
import PageCom from '@/components/PageCom.vue';
import { getGoodsList, goodsAdd, goodsEdit, goodsDelete, uploadGoodsImage, goodsChangeStatus, getGoodsCategoryList } from '@/api/contract';
import { baseURLs } from '@/utils/request';

export default {
  name: 'GoodsManagementView',
  components: {
    PageCom,
  },
  data() {
    return {
      searchQuery: '',
      selectedCategory: '',
      categoryList: [],
      goodsData: [],
      total: 0,
      pageSize: 10,
      currentPage: 1,
      selectedGoods: [], // 存储选中的商品
      // 弹窗相关数据
      dialogVisible: false,
      submitLoading: false,
      dialogTitle: '添加商品',
      isEdit: false,
      form: {
        id: null,
        goods_name: '',
        category_id: '',
        amount: 0,
        discount: 0,
        goods_img: [],
        description: '',
        status: 1
      },
      rules: {
        goods_name: [
          { required: true, message: '请输入商品名称', trigger: 'blur' }
        ],
        category_id: [
          { required: true, message: '请选择商品类别', trigger: 'change' }
        ],
        amount: [
          { required: true, message: '请输入价格', trigger: 'blur' },
          { type: 'number', min: 0, message: '价格必须大于等于0', trigger: 'blur' }
        ]
      },
      // 文件上传相关
      fileList: [],
      // 查看详情相关
      viewDialogVisible: false,
      viewData: {},
      // 字段显示控制配置
      columns: [
        { key: 'selection', label: '', visible: true },
        { key: 'index', label: '序号', visible: true },
        { key: 'goods_name', label: '商品名称', visible: true },
        { key: 'category_name', label: '商品类别', visible: true },
        { key: 'goods_img', label: '商品图片', visible: true },
        { key: 'amount', label: '原价', visible: true },
        { key: 'discount', label: '折扣价', visible: true },
        { key: 'status', label: '状态', visible: true },
        { key: 'create_time', label: '创建时间', visible: true },
        { key: 'operate', label: '操作', visible: true }
      ],
      showColumnSetting: false,
    };
  },
  created() {
    this.fetchCategoryList();
    this.fetchGoodsList();
  },
  methods: {
    formatDate(timestamp) {
      if (!timestamp) return '-';
      
      // 处理不同的时间戳格式
      let date;
      if (typeof timestamp === 'string') {
        date = new Date(timestamp);
      } else if (timestamp.toString().length === 10) {
        date = new Date(timestamp * 1000);
      } else if (timestamp.toString().length === 13) {
        date = new Date(timestamp);
      } else {
        date = new Date(timestamp);
      }
      
      if (isNaN(date.getTime())) {
        return '-';
      }
      
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0');
      const day = String(date.getDate()).padStart(2, '0');
      const hours = String(date.getHours()).padStart(2, '0');
      const minutes = String(date.getMinutes()).padStart(2, '0');
      const seconds = String(date.getSeconds()).padStart(2, '0');
      
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
    // 获取第一张图片
    getFirstImage(goodsImg) {
      if (!goodsImg) return '';
      const images = goodsImg.split(';');
      const firstImg = images[0] || '';
      return this.getFullImageUrl(firstImg);
    },
    // 获取图片列表
    getImageList(goodsImg) {
      if (!goodsImg) return [];
      const images = goodsImg.split(';').filter(img => img.trim());
      return images.map(img => this.getFullImageUrl(img));
    },
    // 获取完整的图片URL
    getFullImageUrl(imagePath) {
      if (!imagePath) return '';
      
      // 如果已经是完整URL，直接返回
      if (imagePath.startsWith('http')) {
        return imagePath;
      }
      
      // 确保路径以 / 开头
      const normalizedPath = imagePath.startsWith('/') ? imagePath : `/${imagePath}`;
      
      // 拼接基础路径
      const baseUrl = baseURLs.replace(/\/$/, ''); // 移除末尾的斜杠
      const fullUrl = `${baseUrl}${normalizedPath}`;
      
      return fullUrl;
    },
    // 获取类别列表
    async fetchCategoryList() {
      try {
        const response = await getGoodsCategoryList();
        if (response.data.code === 200) {
          this.categoryList = response.data.data || [];
        }
      } catch (error) {
        console.error('获取类别列表失败:', error);
      }
    },
    // 获取商品列表数据
    async fetchGoodsList() {
      try {
        const params = {
          page: this.currentPage,
          pageSize: this.pageSize,
          keyword: this.searchQuery || '',
          category: this.selectedCategory || ''
        };
        
        const res = await getGoodsList(params);
        
        if (res.data && res.data.code === 200) {
          const { data } = res.data;
          
          if (!data || !data.data || data.data.length === 0) {
            this.goodsData = [];
            this.total = 0;
            this.$message.info(res.data.msg || '暂无数据');
            return;
          }

          // 确保每条数据都有默认状态值
          const goodsList = data.data || [];
          this.goodsData = goodsList.map(item => ({
            ...item,
            status: item.status !== undefined && item.status !== null ? item.status : 1
          }));
          this.total = data.total || 0;
          this.currentPage = data.current_page || 1;

        } else {
          this.$message.error(res.data.msg || '获取数据失败');
        }
      } catch (error) {
        console.error('获取商品列表失败:', error);
        this.$message.error('获取商品列表失败: ' + error.message);
      }
    },
    handleSearch() {
      this.currentPage = 1;
      this.fetchGoodsList();
    },
    resetSearch() {
      this.searchQuery = '';
      this.selectedCategory = '';
      this.currentPage = 1;
      this.fetchGoodsList();
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.fetchGoodsList();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.fetchGoodsList();
    },
    handleAdd() {
      this.isEdit = false;
      this.dialogTitle = '添加商品';
      this.dialogVisible = true;
      this.$nextTick(() => {
        this.resetForm();
      });
    },
    handleEdit(row) {
      this.isEdit = true;
      this.dialogTitle = '编辑商品';
      
      // 处理图片数据
      let goodsImgArray = [];
      if (row.goods_img) {
        const images = row.goods_img.split(';');
        goodsImgArray = images.filter(img => img.trim());
      }
      
      // 填充表单数据
      this.form = {
        id: row.id,
        goods_name: row.goods_name,
        category_id: row.category_id || '',
        amount: row.amount || 0,
        discount: row.discount || 0,
        goods_img: goodsImgArray,
        description: row.description || '',
        status: row.status !== undefined && row.status !== null ? row.status : 1
      };
      
      // 处理图片文件列表（用于显示）
      this.fileList = [];
      if (row.goods_img) {
        const images = row.goods_img.split(';');
        images.forEach((img, index) => {
          if (img.trim()) {
            const fullUrl = this.getFullImageUrl(img.trim());
            this.fileList.push({
              name: `image_${index}.jpg`,
              url: fullUrl,
              status: 'success'
            });
          }
        });
      }
      
      this.dialogVisible = true;
    },
    handleView(row) {
      this.viewData = { ...row };
      this.viewDialogVisible = true;
    },
    handleDelete(row) {
      this.$confirm('确认要删除该商品吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        try {
          const response = await goodsDelete(row.id);
          if (response.data.code === 200) {
            this.$message.success('删除成功');
            this.fetchGoodsList();
          } else {
            this.$message.error(response.data.msg || '删除失败');
          }
        } catch (error) {
          console.error('删除商品失败:', error);
          this.$message.error('删除失败，请稍后重试');
        }
      }).catch(() => {
        this.$message.info('已取消删除');
      });
    },
    handleStatusChange(row) {
      const statusText = row.status === 1 ? '启用' : '禁用';
      this.$confirm(`确认要${statusText}该商品吗?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        try {
          const response = await goodsChangeStatus(row.id, row.status);
          if (response.data.code === 200) {
            this.$message.success('状态修改成功');
            this.fetchGoodsList();
          } else {
            this.$message.error(response.data.msg || '状态修改失败');
            // 恢复开关状态
            row.status = row.status === 1 ? 0 : 1;
          }
        } catch (error) {
          console.error('状态修改失败:', error);
          this.$message.error('状态修改失败，请稍后重试');
          // 恢复开关状态
          row.status = row.status === 1 ? 0 : 1;
        }
      }).catch(() => {
        // 取消操作，恢复开关状态
        row.status = row.status === 1 ? 0 : 1;
        this.$message.info('已取消操作');
      });
    },
    handleCancel() {
      this.dialogVisible = false;
      this.resetForm();
    },
    resetForm() {
      this.form = {
        id: null,
        goods_name: '',
        category_id: '',
        amount: 0,
        discount: 0,
        goods_img: [],
        description: '',
        status: 1
      };
      this.fileList = [];
      if (this.$refs.form) {
        this.$refs.form.resetFields();
      }
    },
    // 文件上传相关方法
    beforeUpload(file) {
      const isJPG = file.type === 'image/jpeg' || file.type === 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传图片只能是 JPG/PNG 格式!');
        return false;
      }
      if (!isLt2M) {
        this.$message.error('上传图片大小不能超过 2MB!');
        return false;
      }
      
      return true;
    },
    // 自定义上传方法
    async customUpload(options) {
      const { file } = options;
      const { onSuccess, onError } = options;
      
      try {
        this.$message.info('正在上传图片...');
        
        const response = await uploadGoodsImage(file);
        
        if (response.data.code === 200) {
          const imagePath = response.data.path;
          this.form.goods_img.push(imagePath);
          
          const successResponse = {
            url: this.getFullImageUrl(imagePath),
            name: file.name,
            status: 'success'
          };
          
          onSuccess(successResponse, file);
          this.$message.success('图片上传成功');
        } else {
          this.$message.error(response.data.msg || '图片上传失败');
          onError(new Error(response.data.msg || '图片上传失败'));
        }
      } catch (error) {
        console.error('图片上传失败:', error);
        this.$message.error('图片上传失败: ' + error.message);
        onError(error);
      }
    },
    handleRemove(file, fileList) {
      const fileUrl = file.url;
      
      let foundIndex = -1;
      
      for (let i = 0; i < this.form.goods_img.length; i++) {
        const imgPath = this.form.goods_img[i];
        const fullImgUrl = this.getFullImageUrl(imgPath);
        
        if (fullImgUrl === fileUrl || imgPath === fileUrl) {
          foundIndex = i;
          break;
        }
      }
      
      if (foundIndex > -1) {
        this.form.goods_img.splice(foundIndex, 1);
        this.$message.success('图片删除成功');
      } else {
        this.$message.warning('删除失败：未找到对应的图片');
      }
    },
    handleExceed(files, fileList) {
      this.$message.warning(`最多只能上传 5 张图片，当前选择了 ${files.length} 张，共选择了 ${files.length + fileList.length} 张`);
    },
    handlePreview(file) {
      console.log('预览图片:', file);
    },
    handleFileChange(file, fileList) {
      console.log('文件变化:', file, fileList);
    },
    async submitForm() {
      this.$refs.form.validate(async (valid) => {
        if (valid) {
          this.submitLoading = true;
          try {
            const submitData = { ...this.form };
            
            // 将图片数组转换为分号分隔的字符串
            if (submitData.goods_img && Array.isArray(submitData.goods_img)) {
              submitData.goods_img = submitData.goods_img.join(';');
            }
            
            let response;
            if (this.isEdit) {
              response = await goodsEdit(submitData);
            } else {
              response = await goodsAdd(submitData);
            }
            
            if (response.data.code === 200) {
              this.$message.success(response.data.msg || (this.isEdit ? '更新成功' : '添加成功'));
              this.dialogVisible = false;
              this.fetchGoodsList();
            } else {
              this.$message.error(response.data.msg || (this.isEdit ? '更新失败' : '添加失败'));
            }
          } catch (error) {
            if (error.handled) {
              this.$message.error(error.message || '操作失败');
            } else {
              console.error('提交失败:', error);
              this.$message.error('操作失败，请稍后重试');
            }
          } finally {
            this.submitLoading = false;
          }
        }
      });
    },
    handleSelectionChange(selection) {
      this.selectedGoods = selection;
    },
    getColumnVisible(key) {
      const col = this.columns.find(c => c.key === key);
      return col ? col.visible : false;
    },
    resetColumns() {
      this.columns.forEach(col => col.visible = true);
    },
   },
};
</script>

<style scoped>
/* 表格滚动容器样式 */
.table-wrapper {
  margin-top: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .filter-area {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    margin-bottom: 10px;
  }
  
  .filter-area .el-select,
  .filter-area .el-input,
  .filter-area .el-button {
    margin-left: 0 !important;
    margin-right: 10px;
    margin-bottom: 10px;
    width: 100%;
  }
  
  .filter-setting-icon {
    align-self: flex-end;
  }
  
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
  }
  
  .el-table {
    font-size: 12px;
    width: 600px;
  }
}
.goods-management-view {
  padding: 20px;
  background-color: #fff;
  min-height: calc(100vh - 60px);
  box-sizing: border-box;
  width: 100%;
  max-width: none;
}

.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.filter-area {
  display: flex;
  align-items: center;
}

.filter-setting-icon {
  display: flex;
  align-items: center;
  height: 32px;
}

/* 表格样式调整 */
.el-table {
  border: 1px solid #EBEEF5;
  width: 100% !important;
  table-layout: auto;
}

.el-table th {
  background-color: #566275 !important;
  color: #606266;
}

.el-table td, .el-table th {
  border-bottom: 1px solid #EBEEF5;
  border-right: 1px solid #EBEEF5;
}

.el-table th:last-child,
.el-table td:last-child {
  border-right: none;
}

>>> .el-table th.el-table__cell {
  background-color: #f5f7fa !important;
}
.el-table::after, .el-table::before {
  background-color: transparent;
}

/* 确保表格占满容器宽度 */
::v-deep .el-table {
  width: 100% !important;
}

::v-deep .el-table__body-wrapper {
  width: 100% !important;
}

::v-deep .el-table__header-wrapper {
  width: 100% !important;
}

.pagination-container {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.dialog-footer {
  text-align: right;
}

::v-deep .el-input__inner {
  background-color: white !important;
}

/* 图片预览样式 */
.el-image {
  border-radius: 4px;
  cursor: pointer;
}

/* 上传组件样式 */
::v-deep .el-upload--picture-card {
  width: 100px;
  height: 100px;
  line-height: 100px;
}

::v-deep .el-upload-list--picture-card .el-upload-list__item {
  width: 100px;
  height: 100px;
}

</style>

